<?php
/**
 * Created by PhpStorm.
 * User: 17628
 * Date: 2021-12-01
 * Time: 11:04
 */

namespace app\api\controller;


use app\common\controller\Api;

class Pictures extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    //上传图片
    public function upload()
    {        $file = request()->file('image');
        if ($file) {
            $info = $file->move(ROOT_PATH . 'public' . DS . 'avatar');
            if ($info) {
                $a = '/avatar/' . str_replace("\\", "/", $info->getSaveName());
                return sucessMsg('200', '上传成功', $a);
            } else {
                echo $file->getError();
                return errMsg('400', '上传失败');
            }
        }
        return errMsg('', '请上传图片');
    }
}